package algorithm.easy;

import java.util.Arrays;

public class Solution26 {

    public static int removeDuplicates(int[] nums) {
        int p=0,q=0;
        for(int i=0;i<nums.length;i++){
            if(nums[p]!=nums[q]){
                nums[++p] = nums[q];
            }
            q++;
        }
        int[] dest = new int[p+1];
        System.arraycopy(nums,0,dest,0,p+1);
        System.out.println(Arrays.toString(dest));
        return q;
    }

    public static void main(String[] args){
        //输入：nums = [0,0,1,1,1,2,2,3,3,4]
        //输出：5, nums = [0,1,2,3,4]
        int[] nums = {0,0,1,1,1,2,2,3,3,4};
        removeDuplicates(nums);
    }
}
